home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // ==================== expressionEdTextEditor.mel ==========
- //
- // SYNOPSIS
- //
- // CONTENTS
- // (The procs are in the file in the order listed here.)
- //
- // Expression Editor Text Editor and FAM handling routines
- //
- // EEsetActualFileName Replace "|" in object/filenames with "#".
- // EEgetInternalFileName Replace "#" in filenames with "|"
- //
- // EEdoLaunch Do the launch of the user's text editor of choice.
- //
- // EElaunchEditor Launch a text editor for a regular expression.
- // EElaunchParticleEditor Launch a text editor for a particle expression
- // EEupdateFileExpression Update a regular expression from a text editor file.
- // EEupdateParticleFileExpression Update a particle expression from a text
- // editor file.
- // EEdeleteStringElement Delete an element from a string array.
- // EEdeleteIntElement Delete an element from an int array.
- // EEexpressionIsInTextEditor Return whether an expression is in a text editor.
-
- // EEgetFileExpression Callback from TexprEdFamAction.cc when the user
- // writes text editor file to disk. Read file.
- // EEdeleteEditorFile Callback from TexprEdFamAction.cc when user
- // dismisses a text editor. Delete the file.
-
- // ******************************************************************
- //
- // GLOBAL VARIABLES FOR THE TEXT EDITOR MGMT
- //
- // ******************************************************************
- //
-
- // The next 4 lists are parallel, and have all the data necessary for
- // building a regular expression command.
- // EEcurrFiles is the filenames of all files in text editors that are
- // creating/editing regular expressions. EEcurrFileExprName is the name
- // of the expression being create/edited (which might not be the name
- // of the expression. It may contain "" if there is no
- // name yet for an expression being created. EEcurrFileCreateMode contains
- // the create/edit mode of the expression being edited in each editor.
- // EEcurrFileDefObj contains the default object, if any, of the expression
- // being edited/created.
- //
- global string $EEcurrFiles[];
- global string $EEcurrFileExprName[];
- global int $EEcurrFileCreateMode[]; // 1 = creating; 0 = editing
- global string $EEcurrFileDefObj[];
-
- // Count of default filenames.
- //
- global int $EEdefFilenameCount = 0;
-
-
- // ******************************************************************
- //
- // EXPRESSION EDITOR TEXT EDITOR PROCEDURES
- //
-
- // ================ EEsetActualFileName ================
- //
- // SYNOPSIS
- // Since unix will not correctly handle the "|" character in a filename,
- // we have to switch it to something else, so let's use "#".
- //
- proc string EEsetActualFileName(string $fileName)
- {
- // We can't use "subsitute()", because it finds only the first instance
- // in the string. So, tokenize based on "|", and then re-constitute
- // the parts with a # in between each token.
-
- if (size($fileName) == 0)
- return $fileName;
-
- // Make sure to not lose an initial "|"
- //
- string $finalFileName;
- string $firstChar = substring($fileName, 1, 1);
-
- if ($firstChar == "|")
- {
- $finalFileName = "#";
- }
-
- string $buffer[];
- int $numTokens = tokenize($fileName, "|", $buffer);
-
- $finalFileName = $finalFileName + $buffer[0];
- for ($i = 1; $i < $numTokens; $i++)
- {
- $finalFileName = $finalFileName + "#" + $buffer[$i];
- }
-
- return $finalFileName;
- }
-
-
- // ================ EEgetInternalFileName ================
- //
- // SYNOPSIS
- // There may be grouping and non-unique names, in which there
- // will be "|" characters in the object name. But since we can't use
- // "|" in unix file names, we switched them to "#" for the filename.
- // So now switch back to get to the object/expression name again.
- //
- global proc string EEgetInternalFileName(string $fileName)
- {
- if (size($fileName) == 0)
- return $fileName;
-
- // Make sure to not lose an initial "#"
- //
- string $finalFileName;
- string $firstChar = substring($fileName, 1, 1);
-
- if ($firstChar == "#")
- {
- $finalFileName = "|";
- }
-
- string $buffer[];
- int $numTokens = tokenize($fileName, "#", $buffer);
-
- $finalFileName = $buffer[0];
- for ($i = 1; $i < $numTokens; $i++)
- {
- $finalFileName = $finalFileName + "|" + $buffer[$i];
- }
-
- return $finalFileName;
- }
-
-
- // ================ EEdoLaunch ================
- //
- // SYNOPSIS
- // Launch the desired text editor.
- //
- global proc EEdoLaunch(string $exprFile, string $expression)
- {
- global int $EEcurrentEditor;
- int $crFI;
- int $win32 = `exists Win32Init`;
- int $OSMac = `about -mac`;
-
- string $finalFileName = EEsetActualFileName($exprFile);
- $exprFile = $finalFileName;
-
- // Open the temp file in which the user will edit the expression.
- //
- $crFI = fopen($exprFile, "wt" );
- if (size($expression))
- {
- fprint($crFI, $expression+"\n");
- }
- fclose($crFI);
-
- // When invoking the editor 2 commands will be issued: one to invoke
- // the editor, and the other to delete a file, so, since xwsh allows
- // only one command, we have to combine them into a script and have
- // xwsh execute that script. The file to be deleted will be just this
- // executable script. The reason for this is that the expression editor
- // has to know when the user quits the text editor, in order to clean
- // up the temporary files. So when the command script (filename.EXE)
- // is deleted (by itself) this cues the editor to do the cleanup.
- //
- // Set the command script name and contents, open the command script
- // file, write the commands to it, and make it executable.
- //
- string $edCmdString;
- if (`about -irix`)
- {
- string $winEditor;
- string $buffer[];
-
- string $shellCmd = "xwsh -geometry 60x24+0+0 -name " + $exprFile + " -e " ;
- switch($EEcurrentEditor)
- {
- case 2: $edCmdString = "jot -f -p 0,540,1023,640 ";
- break;
- case 3: $edCmdString = $shellCmd + "vi";
- break;
- case 4: $edCmdString = "vim -gf";
- break;
- case 5: $edCmdString = $shellCmd + "xemacs -nw";
- break;
- case 6: $edCmdString = getenv("WINEDITOR");
- tokenize($edCmdString, " ", $buffer);
- break;
- }
- }
- if (`about -linux`)
- {
- string $winEditor;
- string $buffer[];
-
- string $shellCmd = "xterm -geometry 60x24+0+0 -name " + $exprFile + " -e " ;
- switch($EEcurrentEditor)
- {
- case 2: $edCmdString = "emacs";
- break;
- case 3: $edCmdString = "gvim -f";
- break;
- case 4: $edCmdString = $shellCmd + "vi";
- break;
- case 5: $edCmdString = $shellCmd + "vim";
- break;
- case 6: $edCmdString = "xedit";
- break;
- case 7: $edCmdString = "xemacs";
- break;
- case 8: $edCmdString = getenv("WINEDITOR");
- tokenize($edCmdString, " ", $buffer);
- break;
- }
- }
-
- string $exeFile;
- string $fileCmds;
-
- if ($win32==1)
- {
- $exeFile = $exprFile + ".BAT";
- $exeFile = toNativePath($exeFile);
- $fileCmds = "start /WAIT " + $exprFile + "\ndel " + $exeFile;
- }
- else if($OSMac == 1)
- {
- print ("Not yet implemented for Mac\n");
- }
- else
- {
- $exeFile = $exprFile + ".EXE";
- $fileCmds = $edCmdString + " " + $exprFile+";\nrm " + $exeFile + ";";
- }
-
- int $exeFI = fopen ($exeFile, "wt");
- fprint($exeFI, $fileCmds);
- fclose ($exeFI);
-
- if ($win32==0 && $OSMac == 0)
- {
- system("chmod +x " + $exeFile); // gg: unix only
- }
-
- // Build the xwsh command that will launch the editor.
- //
- // Well, don't build it for jot or vim, because they is not going
- // to go in the shell, and we end up with 2 windows. And if users
- // use WINEDITOR, they are on their own.
- //
- string $edCmd;
-
- $edCmd = $exeFile;
-
- // Tell TexprEdListenAction to listen for changes to the text
- // file and the command file. This will register these files to
- // be monitored by FAM.
- //
- expressionEditorListen -lf $exeFile;
- expressionEditorListen -lf $exprFile;
-
- // Launch the editor.
- //
- if ($win32==1) {
- system("shell " +$edCmd+">nul: 2>&1"); // GG: NT only
- }
- else {
- system($edCmd+">/dev/null 2>&1 &"); // GG: unix only
- }
-
- } // EEdoLaunch
-
-
- // ================ EElaunchEditor ================
- //
- // SYNOPSIS
- // Set up to launch a text editor for a regular expression.
- //
- global proc EElaunchEditor( string $fileName,
- string $expression,
- string $expressionName)
- {
- global int $EEcreateMode;
- global int $EEdefFilenameCount;
- global string $EEcurrFiles[];
- global string $EEcurrParticleFiles[];
- global string $EEcurrFileExprName[];
- global string $EEcurrFileDefObj[];
- global int $EEcurrFileCreateMode[];
- global int $EEexpressionInEditor;
- global int $EEpExpressionInEditor;
- global string $EEnodeMode;
-
- int $fileNum = size($EEcurrFiles);
-
- int $win32 = `exists Win32Init`;
- int $OSMac = `about -mac`;
-
- string $exprFile;
-
- // If scriptNodes were used, create a unique script ID from the
- // passed as the $expressionName argument.
- //
- if ($EEnodeMode == "scriptNode")
- {
- $expressionName = EEgetFullScriptName($expressionName);
- }
-
- // Set the name of the temp file the expression will be edited
- // in. Since there may not be an expression name yet, and the
- // expression name may change, give the file a "dummy" name,
- // "exprFile<#>". Also, keep track of the name of the expression
- // being edited in each file and the default object name, if
- // there is one, for initial creation of an expression.
- //
- //
- if (size($expressionName))
- {
- int $index = EEexpressionIsInTextEditor($expressionName, 0);
- if ($index > -1)
- {
- $EEexpressionInEditor = $index;
- $EEpExpressionInEditor = -1;
- warning("The current expression is already in a text editor.");
- return;
- }
- else
- {
- $EEcurrFileExprName[$fileNum] = $expressionName;
- }
- }
- else
- {
- $EEcurrFileExprName[$fileNum] = "";
- }
-
- string $tmpDir;
-
- if ($win32 || $OSMac)
- $tmpDir = getenv ("TMPDIR");
- else
- $tmpDir = "/tmp";
-
- if (size($fileName) > 0)
- {
- $exprFile = $tmpDir + "/" + $fileName;
- }
- else
- {
- $EEdefFilenameCount += 1;
- $exprFile = $tmpDir + "/exprFile" + $EEdefFilenameCount;
- }
-
- // Look through the current list of files and make sure this
- // name is not already there. It could be there, but for
- // another expression. Yes, this is dumb, but there you are.
- //
- int $i, $found, $count = 0;
- int $done = 0;
- string $tmpFile = $exprFile;
-
- while (!$done)
- {
- $found = 0;
-
- for ($i = 0; $i < size($EEcurrFiles); $i++)
- {
- if ($EEcurrFiles[$i] == $tmpFile)
- {
- $tmpFile = $exprFile + "." + ($count + 2);
- $found = 1;
- $count++;
- break;
- }
- }
- if (!$found)
- $done = 1;
- }
- $exprFile = $tmpFile;
-
- if (`exists Win32Init`)
- {
- $exprFile = $exprFile + ".TXT";
- }
-
- // Set a pointer to where in the list of expressions in text editors,
- // the current expression in the Expression Editor is. Add the
- // current expression to the list. Need to keep track of the file
- // name and whether in edit or create mode
- //
- $EEexpressionInEditor = $fileNum;
- $EEpExpressionInEditor = -1;
-
- $EEcurrFileCreateMode[$fileNum] = $EEcreateMode;
- $EEcurrFiles[$fileNum] = $exprFile;
-
- if (`window -exists "expressionEditorWin"`)
- {
- string $defaultObj = `textFieldGrp -q -text EEdefNameT`;
- $EEcurrFileDefObj[$fileNum] = $defaultObj;
- }
- else
- {
- if (size($expressionName) == 0)
- {
- $EEcurrFileCreateMode[$fileNum] = 1;
- $EEcreateMode = 1;
- }
- else
- {
- $EEcurrFileCreateMode[$fileNum] = 0;
- $EEcreateMode = 0;
- }
- }
-
- // Now launch the text editor.
- //
- EEdoLaunch($exprFile, $expression);
-
- } // EElaunchEditor
-
-
- // ================ EElaunchParticleEditor ================
- //
- // SYNOPSIS
- // Set up to launch a text editor for a particle expression.
- //
- global proc EElaunchParticleEditor( string $expression, string $particleName)
- {
- global int $EEisRuntime;
- global string $EEcurrParticleFiles[];
- global int $EEpExpressionInEditor;
- global int $EEexpressionInEditor;
-
- int $index = EEexpressionIsInTextEditor($particleName, 1);
-
- if ($index > -1)
- {
- $EEexpressionInEditor = -1;
- $EEpExpressionInEditor = $index;
- warning("The current expression is already in a text editor.");
- return;
- }
-
- // Set a pointer to where in the list of expressions in text editors,
- // the current expression in the Expression Editor is. Add the
- // current expression to the list.
- //
- int $win32 = `exists Win32Init`;
- int $OSMac = `about -mac`;
- string $tmpDir;
- if ($win32 || $OSMac)
- $tmpDir = getenv("TMPDIR");
- else
- $tmpDir = "/tmp";
-
- string $exprFile = $tmpDir + "/" + $particleName;
-
- if ($EEisRuntime)
- $exprFile = $exprFile + ".runtime";
- else
- $exprFile = $exprFile + ".creation";
-
- if ($win32 || $OSMac)
- $exprFile = $exprFile + ".TXT";
-
- $EEpExpressionInEditor = size($EEcurrParticleFiles);
- $EEexpressionInEditor = -1;
- $EEcurrParticleFiles[size($EEcurrParticleFiles)] = $exprFile;
-
- // Launch the text editor.
- //
- // Set up the filename for the temp file to edit the expression in.
- //
- EEdoLaunch($exprFile, $expression);
-
- } // EElaunchParticleEditor
-
-
-
- // ================ EEupdateFileExpression ================
- //
- // SYNOPSIS
- // A text editor file has been written. So get its contents
- // and update the expression and the Expression Editor.
- //
- global proc EEupdateFileExpression(string $fileName,
- string $expression, int $isCurrent)
- {
- global string $EEcurrFiles[];
- global string $EEcurrFileExprName[];
- global string $EEcurrFileDefObj[];
- global int $EEcurrFileCreateMode[]; // 1 = creating; 0 = editing
- global int $EEeditedInEditor;
-
- string $newExprName;
-
- // Find the file in the list.
- //
- int $i, $index = -1;
-
- for ($i = 0; $i < size($EEcurrFiles); $i++)
- {
- if ($fileName == $EEcurrFiles[$i])
- {
- $index = $i;
- break;
- }
- }
-
- if ($index == -1)
- return;
-
- // Find out if editing or creating this expression.
- //
- int $creating = $EEcurrFileCreateMode[$index];
-
- // Make sure the expression can get through MEL.
- //
- string $newExprName;
-
- if ($creating)
- {
- // If creating and the expression is currently in the Expression
- // Editor, need to do other flags as well, so call the same
- // procedure as when selecting the create button.
- // Otherwise just edit the expression itself..
- //
- // Don't try to make an expression node if there's no expression.
- //
- if ($expression == "")
- return;
-
- if ($isCurrent)
- {
- $newExprName = EEapplyExpression($expression);
-
- $EEcurrFileExprName[$index] = $newExprName;
-
- // Re-call EEdisplayExpression now that the expression name is
- // in $EEcurrFileExprName. Otherwise the editor thinks it is
- // not in text editor mode.
- //
- EEdisplayExpression($newExprName);
- }
- else
- {
- if (size($EEcurrFileDefObj[$index]))
- {
- string $theCommand = ("expression -s \""+encodeString($expression)+"\" -o "+$EEcurrFileDefObj[$index]+";");
- $newExprName = evalEcho( $theCommand );
- }
- else
- {
- string $theCommand = ("expression -s \""+encodeString($expression)+"\";");
- $newExprName = evalEcho( $theCommand );
- }
- $EEcurrFileExprName[$index] = $newExprName;
- }
-
- // No longer in create mode.
- //
- $EEcurrFileCreateMode[$index] = 0;
-
-
- }
- else
- {
- // Editing. So just edit the expression, and update the
- // Expression Editor scroll field.
- //
- string $theCommand = ("expression -e -s \"" + encodeString($expression) +"\" " + $EEcurrFileExprName[$index] + ";");
- $newExprName = evalEcho( $theCommand );
-
- if ($isCurrent)
- {
- $EEeditedInEditor = 1;
- scrollField -e -text $expression EEmultiText;
- }
- }
-
- } // EEupdateFileExpression
-
-
- // ================ EEupdateParticleFileExpression ================
- //
- // SYNOPSIS
- // A text editor file has been written. So get its contents
- // and update the expression and the Expression Editor.
- //
- global proc EEupdateParticleFileExpression(string $fileName,
- string $expression,
- int $isCurrent)
- {
- string $buffer[];
-
- // The filename for particle expression is composed of:
- // /tmp/<obj>.runtime/create. So get the individual tokens.
- //
- tokenize ($fileName, ".", $buffer);
- string $temp = $buffer[0];
- string $runCreate = $buffer[1];
- tokenize($temp, "/", $buffer);
- string $nodeName = $buffer[size($buffer) - 1];
-
- string $exprReturn;
-
- if ($isCurrent)
- {
- // If the particle/expression is currently in the Expression
- // Editor, do the same as if the "Create/Edit" button had been
- // pressed.
- //
- EEapplyParticleExpression($expression);
- }
- else
- {
- int $isRuntime;
- if ($runCreate == "runtime")
- $isRuntime = 1;
- else
- $isRuntime = 0;
-
- // Edit the particle expression and Print the command to the
- // command window.
- //
- EEdynExpressionCmd($isRuntime, $expression, $nodeName);
- }
-
- } // EEupdateParticleFileExpression
-
-
-
- // ================ EEdeleteStringElement ================
- //
- // SYNOPSIS
- // Remove an element from a string array.
- //
- global proc string[] EEdeleteStringElement(string $array[], int $i)
- {
- string $tmp[];
- int $j;
-
- int $lastElemIndex = size($array) - 2;
-
- for ($j = 0; $j < $i; $j++)
- $tmp[$j] = $array[$j];
-
- for ($j = $i; $j <= $lastElemIndex; $j++)
- $tmp[$j] = $array[$j+1];
-
- return $tmp;
-
- } // EEdeleteStringElement
-
-
- // ================ EEdeleteIntElement ================
- //
- // SYNOPSIS
- // Remove an element from an int array.
- //
- global proc int[] EEdeleteIntElement(int $array[], int $i)
- {
- int $tmp[];
- int $j;
-
- int $lastElemIndex = size($array) - 2;
-
- for ($j = 0; $j < $i; $j++)
- $tmp[$j] = $array[$j];
-
- for ($j = $i; $j <= $lastElemIndex; $j++)
- $tmp[$j] = $array[$j+1];
-
- return $tmp;
-
- } // EEdeleteIntElement
-
-
- // ================ EEexpressionIsInTextEditor ================
- //
- // SYNOPSIS
- // Return whether the expression is already in a text editor.
- //
- global proc int EEexpressionIsInTextEditor(string $expressionName, int $isParticle)
- {
- global int $EEisRuntime;
- global string $EEcurrFiles[];
- global string $EEcurrParticleFiles[];
- global string $EEcurrFileExprName[];
- global string $EEnodeMode;
-
- // If scriptNodes were used, create a unique script ID from the
- // passed as the $expressionName argument.
- //
- if ($EEnodeMode == "scriptNode")
- {
- $expressionName = EEgetFullScriptName($expressionName);
- }
-
- // Look through the list of expressions in text editors. If this one
- // is there, return its index in the list, otherwise return -1.
-
- if ($isParticle)
- {
- int $i;
- string $exprFile = "/tmp/" + $expressionName;
-
- if ($EEisRuntime)
- $exprFile = $exprFile + ".runtime";
- else
- $exprFile = $exprFile + ".creation";
-
- for ($i = 0; $i < size($EEcurrParticleFiles); $i++)
- {
- if ($exprFile == $EEcurrParticleFiles[$i])
- {
- return $i;
- }
- }
- }
- else
- {
- for ($i = 0; $i < size($EEcurrFileExprName); $i++)
- {
- // Test for the filename, in EEcurrFileExprName.
- //
- if ($expressionName == $EEcurrFileExprName[$i])
- {
- return $i;
- }
- }
- }
-
- return -1;
-
- } // EEexpressionIsInTextEditor
-
-
- // ******************************************************************
- //
- // EXPRESSION EDITOR FAM "CALLBACKS"
- //
- //
- // ================ EEgetFileExpression ================
- //
- // SYNOPSIS
- // Get/read the expression from the temp file on disk. This
- // procedure is called from TexprEdFamListen (.cc), when FAM
- // has signalled that the file has been modified.
- //
- global proc EEgetFileExpression(string $fileName)
- {
- global int $EEcurrentEditor;
- global string $EEcurrParticleFiles[];
- global string $EEcurrFiles[];
- global int $EEpExpressionInEditor;
- global int $EEexpressionInEditor;
- global string $EEnodeMode;
-
- string $expression;
-
- // Read the expression from the file.
- //
- int $fd = fopen($fileName, "rt");
-
- if ($fd == 0)
- {
- warning("ExpressionEditor: couldn't open "+$fileName);
- return;
- }
-
- string $tmpExpr;
- for ($tmpExpr = ""; !`feof $fd`;)
- {
- $tmpExpr += fgetline ($fd);
- }
- fclose ($fd);
-
- int $lastIndex = size($tmpExpr);
-
- // If vi or vim, get rid of an odd character at the end of the file.
- //
-
- if ($EEcurrentEditor == 3 || $EEcurrentEditor == 4
- || (`about -linux` && $EEcurrentEditor == 5))
- {
- if (size($tmpExpr) > 2)
- $tmpExpr = substring($tmpExpr, 1, $lastIndex - 1);
- }
-
-
- $expression = $tmpExpr;
-
- // There may be grouping and non-unique names, in which there
- // will be "|" characters in the object name. But since we can't use
- // "|" in unix file names, we switched them to "#" for the filename.
- // So now we have to switch back to get to the object/expression name again.
- //
- $internalFileName = EEgetInternalFileName($fileName);
- $fileName = $internalFileName;
-
- // If this expression is currently in the expression editor,
- // update the text field, and find out if it is a particle.
- //
- int $expressionIsCurrent = 0;
- int $nodeIsParticle = 0;
-
- if (`window -exists "expressionEditorWin"`)
- {
- if ($EEpExpressionInEditor >= 0)
- {
- if ($EEcurrParticleFiles[$EEpExpressionInEditor] == $fileName)
- {
- $expressionIsCurrent = 1;
- $nodeIsParticle = 1;
- }
- }
- else if ($EEexpressionInEditor >= 0)
- {
- if ($EEcurrFiles[$EEexpressionInEditor] == $fileName)
- {
- $expressionIsCurrent = 1;
- }
- }
-
- if ($expressionIsCurrent)
- scrollField -e -text $expression EEmultiText;
- }
-
- // Update the expression node -- have to know if it is a
- // particle or a regular expression.
- //
- if (!$nodeIsParticle)
- {
- for ($i = 0; $i < size($EEcurrParticleFiles); $i++)
- {
- if ($fileName == $EEcurrParticleFiles[$i])
- {
- $nodeIsParticle = 1;
- break;
- }
- }
- }
-
- if ($nodeIsParticle)
- EEupdateParticleFileExpression($fileName, $expression, $expressionIsCurrent);
- else
- {
- if ($EEnodeMode == "scriptNode")
- EEupdateFileScript($fileName, $expression, $expressionIsCurrent);
- else
- EEupdateFileExpression($fileName, $expression, $expressionIsCurrent);
- }
-
- } // EEgetFileExpression
-
-
- // ================ EEdeleteEditorFile ================
- //
- // SYNOPSIS
- // Delete a temp file from disk. This procedure is called from
- // TexprEdFamListen (.cc), when FAM has signalled that the .EXE
- // file connected with this text file has been deleted. Now
- // need to delete this text file as well.
- //
- global proc EEdeleteEditorFile(string $fileName)
- {
- global int $EEcurrentEditor;
- global string $EEcurrParticleFiles[];
- global string $EEcurrFiles[];
- global string $EEcurrFileExprName[];
- global string $EEcurrFileDefObj[];
- global int $EEcurrFileCreateMode[]; // 1 = creating; 0 = editing
- global int $EEpExpressionInEditor;
- global int $EEexpressionInEditor;
-
- sysFile -del $fileName;
-
- // There may be grouping and non-unique names, in which there
- // will be "|" characters in the object name. But since we can't use
- // "|" in unix file names, we switched them to "#" for the filename.
- // So now we have to switch back to get to the object/expression name again.
- //
- $internalFileName = EEgetInternalFileName($fileName);
- $fileName = $internalFileName;
-
- // Remove the file from the list.
- //
- int $removed = 0;
- int $i;
- for ($i = 0; $i < size($EEcurrParticleFiles); $i++)
- {
- if ($fileName == $EEcurrParticleFiles[$i])
- {
- int $j;
-
- $EEcurrParticleFiles = EEdeleteStringElement($EEcurrParticleFiles, $i);
- // If the deleted file holds the expression that is current
- // in the editor, re-enable the expression textfield.
- //
- if ($EEpExpressionInEditor == $i)
- {
- $EEpExpressionInEditor = -1;
- if (`window -exists "expressionEditorWin"`)
- scrollField -e -enable true EEmultiText;
- }
- else
- {
- // If the current file index is greater than the index
- // of the element that got removed, decrement it by one.
- //
- if ($EEpExpressionInEditor > $i)
- $EEpExpressionInEditor -= 1;
- }
- $removed = 1;
- break;
- }
- }
- // If editor has been switched to Expression Editor while an expression
- // is in a text editor, if this is the last file in the editor,
- // then switch the scroll field back to enabled mode.
- //
- if (!$removed)
- {
- for ($i = 0; $i < size($EEcurrFiles); $i++)
- {
- if ($fileName == $EEcurrFiles[$i])
- {
- $EEcurrFiles = EEdeleteStringElement($EEcurrFiles, $i);
-
- $EEcurrFileExprName =
- EEdeleteStringElement($EEcurrFileExprName, $i);
-
- $EEcurrFileDefObj =
- EEdeleteStringElement($EEcurrFileDefObj, $i);
-
- $EEcurrFileCreateMode =
- EEdeleteIntElement($EEcurrFileCreateMode, $i);
-
- // If the deleted file holds the expression that is current
- // in the editor, re-enable the expression textfield.
- //
- if ($EEexpressionInEditor == $i)
- {
- if (`window -exists "expressionEditorWin"`)
- scrollField -e -enable true EEmultiText;
- $EEexpressionInEditor = -1;
- }
- else
- {
- // If the current file index is greater than the index
- // of the element that got removed, decrement it by one.
- //
- if ($EEexpressionInEditor > $i)
- $EEexpressionInEditor -= 1;
- }
- break;
- }
- }
- }
-
- if (`window -exists "expressionEditorWin"`)
- {
- if ($EEcurrentEditor == 1 && size($EEcurrFiles) == 0)
- scrollField -e -enable true EEmultiText;
- }
-
- } // EEdeleteEditorFile
-
-
-
-
-